#!/usr/bin/env bash
set -e
[ -n "$PLENV_DEBUG" ] && set -x

# Provide plenv completions
if [ "$1" = "--complete" ]; then
  exec plenv-rehash --complete
fi

shell="${PLENV_SHELL:-$SHELL}"
shell="${shell##*/}"

# When plenv shell integration is enabled, delegate to plenv-rehash,
# then tell the shell to empty its command lookup cache.
plenv-rehash
case "$shell" in
fish)
  # no rehash support
  ;;
* )
  echo "hash -r 2>/dev/null || true"
  ;;
esac
